from tkinter import *
from tkinter.messagebox import *
root = Tk();root.title("周雨晴的个人信息调查")
f1 = Frame(root); f1.pack()
f2 = Frame(root); f2.pack()
f3 = Frame(root); f3.pack()
f4 = Frame(root); f4.pack()
f5 = Frame(root); f5.pack()
Label(f1, text="个人信息调查").pack(side='left')
Label(f2, text="姓名").pack(side=LEFT)
w9=Entry(f2)
w9.pack(side=LEFT)
Label(f3, text="性别").pack(side=LEFT)
v = StringVar();v.set('M')
w1 = Radiobutton(f3, text="男", value='男', variable=v)
w2 = Radiobutton(f3, text="女", value='女', variable=v)
w1.pack(side=LEFT)
w2.pack(side=LEFT)
Label(f4,text="爱好").pack(side=LEFT)
u1=StringVar();u1.set('no')
u2=StringVar();u2.set('no')
u3=StringVar();u3.set('no')
u4=StringVar();u4.set('no')
w3= Checkbutton(f4, text="音乐", variable=u1, onvalue='yes', offvalue='no')
w4= Checkbutton(f4, text="运动", variable=u2, onvalue='yes', offvalue='no')
w5= Checkbutton(f4, text="旅游", variable=u3, onvalue='yes', offvalue='no')
w6= Checkbutton(f4, text="影视", variable=u4, onvalue='yes', offvalue='no')
w3.pack(side=LEFT);u1.get()
w4.pack(side=LEFT);u2.get()
w5.pack(side=LEFT);u3.get()
w6.pack(side=LEFT);u4.get()
w7=Button(f5,text="提交")
w7.pack(side=LEFT)
w8=Button(f5,text="取消").pack(side=RIGHT,padx=20)
def grxx(p):
    strl=w9.get()+"您好\n"
    strl+="您的性别是:"+v.get()+'\n'
    strl+="你的爱好是:"
    if u1.get()=="yes":strl+=w3['text']+' '
    if u2.get()=="yes":strl+=w4['text']+' '
    if u3.get()=="yes":strl+=w5['text']+' '
    if u4.get()=="yes":strl+=w6['text']+' '
    askokcancel("提交成功",strl)
w7.bind("<Button-1>",grxx)
root.mainloop()
